package com.tange.module.device.feature;

import com.alibaba.fastjson.JSON;
import com.appbase.custom.base.DeviceFeatureSettings;
import com.tange.core.device.facade.DeviceFacade;
import com.tange.core.device.facade.Instruction;
import com.tg.app.camera.AVIOCTRLDEFs;
import com.tg.app.camera.Camera;
import com.tg.data.bean.DeviceItem;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class DeviceInteraction {

    private DeviceFacade deviceFacade;

    public static DeviceInteraction create(DeviceFacade deviceFacade) {
        return new DeviceInteraction(deviceFacade);
    }

    private DeviceInteraction(DeviceFacade deviceFacade) {
        this.deviceFacade = deviceFacade;
    }

    /**
     * 获取设备能力等级
     */
    public void getFeatureList() {
        if (deviceFacade == null) {
            return;
        }

        DeviceFeatureSettings.DeviceFeatureSettingsReq feature = new DeviceFeatureSettings.DeviceFeatureSettingsReq();
        feature.uuid = deviceFacade.getDeviceId();
        List<String> features = new ArrayList<>();
        features.add(DeviceFeature.FEATURE_TYPE_AUTOTRACKING);
        features.add(DeviceFeature.FEATURE_TYPE_SUPPORTPTZ);
        features.add(DeviceFeature.FEATURE_TYPE_DAYNIGHT);
        features.add(DeviceFeature.FEATURE_TYPE_DOUBLELIGHT);
        features.add(DeviceFeature.FEATURE_TYPE_MICROPHONE);
        features.add(DeviceFeature.FEATURE_TYPE_ALERTSOUND);
        features.add(DeviceFeature.FEATURE_TYPE_MOTION_DETECTION);
        features.add(DeviceFeature.FEATURE_TYPE_CAP_DEFENCE);
        features.add(DeviceFeature.FEATURE_TYPE_CAP_ZOOM);
        features.add(DeviceFeature.FEATURE_TYPE_CAP_AI);
        features.add(DeviceFeature.FEATURE_TYPE_CAP_INSTRUCTIONS);
        features.add(DeviceFeature.FEATURE_TYPE_MULTICHANNELS);
        features.add(DeviceFeature.FEATURE_G_SENSOR);

        feature.feature = features;

        String[] settingArr = new String[]{"SDFree", "SDTotal", "DeviceType", "vendor", "version", /*"streamQuality",*/
                "SDRecordMode", "mirrorMode", "PowerFrequency", "trackMode", "nightVision",
                "doubleLightMode ", "doubleLightStatus", "CVideoQuality", "Microphone", "AlertSound", "Buzzer", "MultiChannels"};
        feature.setting = Arrays.asList(settingArr);
        deviceFacade.getInstruct().sendInternal(new Instruction(AVIOCTRLDEFs.IOTYPE_USEREX_IPCAM_GET_FEATURE_REQ, JSON.toJSONBytes(feature)));
    }
}
